home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / c_course.zip / READCHAR.C < prev    next >
C/C++ Source or Header  |  1989-12-30  |  469b  |  21 lines

  1. /*  READCHAR.C  putchar()    if fopen points to NULL   */
  2.  
  3. #include "stdio.h"
  4.  
  5. main()
  6. {
  7. FILE *funny;
  8. int c;
  9.  
  10.    funny = fopen("TENLINES.TXT","r");
  11.  
  12.    if (funny == NULL) printf("File doesn't exist\n");
  13.    else {
  14.       do {
  15.          c = getc(funny);    /* get one character from the file */
  16.          putchar(c);         /* display it on the monitor       */
  17.       } while (c != EOF);    /* repeat until EOF (end of file)  */
  18.    }
  19.    fclose(funny);
  20. }
  21.